package com.tws.pctask.controller;

import com.tws.common.model.ResponseWrapper;
import com.tws.pctask.model.loginManageModel.GetTokenParam;
import com.tws.pctask.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Description： 登录模块控制层
 * @Author: wbf
 * @Date: 2022/1/15 21:57
 */
@RestController
@RequestMapping("common/loginManage")
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 1.1获取图形验证码
     * @return 图形验证码
     */
    @GetMapping("getImageCode")
    public ResponseWrapper getImageCode(){
        return loginService.getImageCode();
    }

    /**
     * 1.2登陆验证
     * @return 唯一token
     */
    @PostMapping("getToken")
    public ResponseWrapper loginCheck(@Validated GetTokenParam param){
        return loginService.loginCheck(param);
    }

    /**
     * 1.3获取用户姓名
     * @return 用户姓名
     */
    @GetMapping("getUserName")
    public ResponseWrapper getUserName(){
        return ResponseWrapper.markSuccess(LoginService.getLoginUser().getUserName());
    }
}
